<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>修改员工</h1>
<form>
    ID：<input type="text"  v-model="emp.id" placeholder="ID" readonly><br>
    姓名:<input type="text" v-model="emp.name"  placeholder="姓名"><br>
    工作:<input type="text" v-model="emp.job"  placeholder="工作"><br>
    工资:<input type="text" v-model="emp.sal"   placeholder="工资"><br>
    <input type="button" value="修改" @click="update()"><br>
</form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{
            emp:{id:"",name:"",job:"",sal:""}
        },
        methods:{
            update(){

                //发起修改员工的异步请求
                axios.post("/update",v.emp).then(function () {
                    location.href="/select.html";
                })
            }
        },
        created(){
            //location.search获取地址栏中从”？“开始的的内容   比如"?id=8"
            axios.get("/selectOne"+location.search).then(function (response) {
                v.emp = response.data;
            });
        }
    })
</script>

</body>
</html>